package com.zt.student.controller;

import com.zt.common.common.ApiException;
import com.zt.common.common.CodeMsg;
import com.zt.common.pojo.common.JsonResult;
import io.swagger.annotations.Api;
import org.apache.shiro.authc.AuthenticationException;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;

/**
 * description:
 * author:zt
 * date:2021-12-04
 */
@RestController
@CrossOrigin
@RequestMapping("exception")
@Api("接受异常模块")
public class ExceptionController {

    //接受登录验证出现的异常
    @RequestMapping("/unauthorized/{message}")
    public JsonResult<String> unauthorized(@PathVariable String message) throws UnsupportedEncodingException {
        throw new AuthenticationException(message);
    }

    @RequestMapping("/tokenExpire")
    public JsonResult<String> tokenExpire() {
        throw new ApiException(CodeMsg.TOKEN_EXPIRE);
    }
}
